<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/14 0014
 * Time: 09:51
 */

namespace app\currency\controller;

use app\currency\service\MemberService;
use library\Controller;
use think\Db;

/**
 * 会员信息管理
 * Class Member
 * @package app\currency\controller
 */
class Member extends Controller
{
    protected $table = 'Member';

    /**
     * 会员列表
     * @menu true
     * @auth true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $this->title = '会员信息管理';
        $this->_query($this->table)
            ->like('nickname,phone')->equal('status')
            ->dateBetween('create_at')
            ->order('id desc')
            ->page();
    }

    /**
     * 禁用
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function forbid()
    {
        $this->applyCsrfToken();
        $this->_save($this->table, ['status' => '0']);
    }

    /**
     * 启用
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function resume()
    {
        $this->applyCsrfToken();
        $this->_save($this->table, ['status' => '1']);
    }

    /**
     * 删除
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */
    public function remove()
    {
        $this->applyCsrfToken();
        $this->_delete($this->table);
    }
}